const state = {
    count: 0,
    num: 0,
  };
  const mutations = {
    /* mutations的方法会接受state作为第一个参数 */
    increament(state) {
      state.count++;
    },
    increamentN(state, payload) {
      state.count += payload.n;
    },
  };
  const actions = {
    incrementWait({ commit }) {
      setTimeout(() => {
        commit("increament");
      }, 1000);
    },
    incrementNWait({ commit }, payload) {
      setTimeout(() => {
        commit("increamentN", payload);
      }, 1000);
    },
  };
  const getters = {
    countSqrt(state) {
      return Math.sqrt(state.count);
    },
  };
  
  export default {
    namespaced: true,
    state,
    mutations,
    actions,
    getters,
  };